package com.jinbo.sxzq;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

public class WelcomeActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        Button pve_star = findViewById(R.id.PVE_star);
        Button pvp_star = findViewById(R.id.PVP_star);
        Button introduction_star = findViewById(R.id.introduction_star);
        Button game_exit = findViewById(R.id.game_exit);
        pve_star.setOnClickListener(onClickListener);
        pvp_star.setOnClickListener(onClickListener);
        introduction_star.setOnClickListener(onClickListener);
        game_exit.setOnClickListener(onClickListener);
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            Button bt = (Button)v;
            switch (bt.getId()){
                case R.id.PVE_star:
                    intent.setClass(WelcomeActivity.this,LevelSelectActivity.class);
                    startActivity(intent);
                    break;
                case R.id.PVP_star:
                    intent.setClass(WelcomeActivity.this,GameActivity.class);
                    startActivity(intent);
                    break;
                case R.id.introduction_star:
                    intent.setClass(WelcomeActivity.this,IntroductionActivity.class);
                    startActivity(intent);
                    break;
                case R.id.game_exit:
                    finish();
            }
        }
    };
}
